import { EggAppConfig, EggAppInfo, PowerPartial } from 'midway';
import * as path from 'path'
export type DefaultConfig = PowerPartial<EggAppConfig>;

export default (appInfo: EggAppInfo) => {
  const config = {} as DefaultConfig;

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_{{keys}}';

  // add your config here
  config.middleware = [
  ];

  config.view = {
    defaultViewEngine: 'nunjucks',
    defaultExtension: '.html',
  };

  config.static = {
    prefix: '/',
    dir: path.join(appInfo.baseDir, 'app/public'),
  };


  config.security={
    csrf:{
      enable:false
    }
  }

  config.cluster = {
    listen: {
      port: 7001,
      hostname: '0.0.0.0',
    }
  };
  config.typeorm = {
    "type": "mysql",
    "host": "94.191.121.109",
    "port": 3306,
    "username": "root",
    "password": "pluto1114",
    "database": "shop",
    "synchronize": false,
    "logging": true,
    "entityPrefix":"t_",
    "entities": [
        "src/entity/**/*.ts",
        "dist/entity/**/*.js"
    ],
    migrations: ['src/migration/**/*.ts'],
    subscribers: ['src/subscriber/**/*.ts'],
    cli: {
      entitiesDir: 'src/entity',
      migrationsDir: 'src/migration',
      subscribersDir: 'src/subscriber',
    },
  }
  return config;
};
